class Solution(object):
    def countNumbersWithUniqueDigits(self, n):
        """
        :type n: int
        :rtype: int
        """
        def cal(k):
            if k == 0:
                return 1
            if k == 1:
                return 9
            base = 9
            for i in range(k - 1):
                base *= (9 - i)
            return base
        return sum([cal(k) for k in range(0, n + 1)])


data = Solution()
n = 2
print(data.countNumbersWithUniqueDigits(n))
